package com.cnap.multiclouldmgmt.service.impl;

import com.cnap.multiclouldmgmt.MulticlouldmgmtApplicationTests;
import com.cnap.multiclouldmgmt.model.k8sModels.K8sClusterBasicModel;
import com.cnap.multiclouldmgmt.model.k8sModels.K8sClusterModel;
import com.cnap.multiclouldmgmt.service.CacheService;
import com.cnap.multiclouldmgmt.service.MultiCloudMgmtService;
import io.fabric8.kubernetes.api.model.*;
import io.fabric8.kubernetes.api.model.authentication.TokenReview;
import io.fabric8.kubernetes.api.model.certificates.v1beta1.CertificateSigningRequest;
import io.fabric8.kubernetes.api.model.certificates.v1beta1.CertificateSigningRequestList;
import io.fabric8.kubernetes.api.model.coordination.v1.Lease;
import io.fabric8.kubernetes.api.model.coordination.v1.LeaseList;
import io.fabric8.kubernetes.api.model.node.v1beta1.RuntimeClass;
import io.fabric8.kubernetes.api.model.node.v1beta1.RuntimeClassList;
import io.fabric8.kubernetes.client.*;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.dsl.*;
import io.fabric8.kubernetes.client.dsl.base.ResourceDefinitionContext;
import io.fabric8.kubernetes.client.extended.leaderelection.LeaderElectorBuilder;
import io.fabric8.kubernetes.client.extended.run.RunOperations;
import io.fabric8.kubernetes.client.http.HttpClient;
import io.fabric8.kubernetes.client.informers.SharedInformerFactory;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;

import java.io.InputStream;
import java.net.URL;
import java.util.Collection;

import static org.junit.jupiter.api.Assertions.*;

class CacheServiceImplTest extends MulticlouldmgmtApplicationTests {

    @MockBean
    private MultiCloudMgmtService multiCloudMgmtService;

    @Autowired
    private CacheService cacheService;

    @Test
    void getK8sBasicModel() {
        K8sClusterBasicModel k8sClusterBasicModel = new K8sClusterBasicModel();
        k8sClusterBasicModel.setK8sClusterName("clusternameTest");
        Mockito.when(multiCloudMgmtService.getK8sClusterInfoByName("clusternameTest"))
                .thenReturn(k8sClusterBasicModel);

        cacheService.getK8sBasicModel("clusternameTest");
        
    }

    @Test
    void putK8sBasicModel() {

        cacheService.putK8sBasicModel("test",new K8sClusterBasicModel());
    }

    @Test
    void putK8sClient() {
        cacheService.putK8sClient("1.2.3.4", new DefaultKubernetesClient());
    }

    @Test
    void getK8sClient() {

        cacheService.getK8sClient("1.2.3.4");
    }

    @Test
    void removeK8sClient() {
        cacheService.removeK8sClient("1,2,3,4");
    }

    @Test
    void getK8sIps() {
        cacheService.putK8sClient("1.2.3.4",new DefaultKubernetesClient());
        cacheService.getK8sIps();
    }

    @Test
    void putK8sPodModels() {
    }

    @Test
    void getK8sPodModels() {
    }

    @Test
    void putVmCreateSvc() {
        cacheService.putVmCreateSvc("svcId");
    }

    @Test
    void getVmCreateTime() {
        cacheService.putVmCreateSvc("svcId");
        cacheService.getVmCreateTime("svcId");
        cacheService.getVmCreateTime("svcTEst");
    }

    @Test
    void delVmCreate() {

        cacheService.delVmCreate("svcId");
    }
}